package com.jk.common.enums;

import lombok.Getter;

@Getter
public enum DeletedStatusEnum {
    // 0未删除 1已删除
    UNDELETED((byte) 0, "未删除"),
    DELETED((byte) 1, "已删除"),
    ;
    private final byte code;
    private final String message;

    DeletedStatusEnum(byte code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 根据错误码查找对应的枚举
     *
     * @param code 错误码
     * @return 对应的枚举
     */
    public static DeletedStatusEnum fromCode(byte code) {
        for (DeletedStatusEnum errorCode : DeletedStatusEnum.values()) {
            if (errorCode.getCode() == code) {
                return errorCode;
            }
        }
        throw new IllegalArgumentException("未知的错误码: " + code);
    }
}
